package com.diankangwo.dao.impl;

import com.diankangwo.dao.UserWalletDao;
import com.diankangwo.domain.UserInfo;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class UserWalletDaoImpl extends BaseDaoImpl<UserInfo> implements UserWalletDao {
    @Override
    public UserInfo findByUserWallet(String token) {
        List<UserInfo> userList = new ArrayList<UserInfo>();
        userList =  findByQuery("from UserInfo user where user.accessToken = ?", token);
        if (userList == null || userList.size() ==0) {
            return null;
        }else{
            UserInfo user = userList.get(0);
            user.setGetui_cid("");
            user.setSalt_value("");
            user.setPassword("");
            user.setRoles(null);
            return user;
        }
    }
}
